<?php
	
	if(isset($_GET["ID"]) ){
		$acao = 'item';
		$IDITEM = $_GET['IDITEM'];
		
	}else if(isset($_GET['IDITEM'])){
		$IDITEM = $_GET['IDITEM'];
		$acao = 'Subitem';
	}else{
		$acao = 'sem dados';
	}

	if($acao == 'item'){
		$sql_iten = mysql_query("SELECT id,id_menu, nome, descricao FROM tbl_itens WHERE id='".$ID."'");
		list($id,$id_menu,$titulo_secao,$desc_secao) = mysql_fetch_array($sql_iten);
	}else if($acao == 'Subitem'){
		$sql_sub_iten = mysql_query("SELECT ts.codigo,ts.nome,ts.descricao,ts.data,ts.arquivo,ti.nome FROM tbl_subitens ts INNER JOIN tbl_itens ti on(ts.cod_itens=ti.id) WHERE codigo = ".$IDITEM."");
		list($codigo,$nome,$descricao,$data,$arquivo,$item) = mysql_fetch_array($sql_sub_iten);
	}else{
	
	}
	
	if($acao == 'item'){
	?>	
        <p style="margin-left:10px;">
        <span><font face="Tahoma, Geneva, sans-serif" size="3"><?php echo $titulo_secao; ?><br />
        </font></span>
        </p>
        <div style="margin-left:10px;">
        <p style="margin-left:10px;">
        <span><font face="Tahoma, Geneva, sans-serif" size="3"><?php echo $desc_secao; ?><br />
        </font></span>
        </p>
        </div>

		<?php 
        $sql_arq = mysql_query("SELECT arquivo FROM arquivos WHERE id_iten = $id ");
        $sql_num_arq = mysql_num_rows($sql_arq);
            if($sql_num_arq > 0) {
            while(list($arquivo)=mysql_fetch_array($sql_arq)){
            ?>
                <span style="margin-left:10px;">
                    <img src="img/icones/pdf_novo.png" />
                    <a title="Visualizar" style="vertical-align:top;text-decoration:none;color:black;font-family:Tahoma, Geneva, sans-serif;" target="_blank" href="../intranet/<?php echo $arquivo; ?>"><?php echo $arquivo; ?></a>
                    <a href="inc/baixar.php?arquivo=<?php echo $arquivo; ?>" title="Baixar">
                    <img src="img/icones/download.png" />
                    </a>
                </span>
                <br />
            <?php 
                }
            }
            ?>


	<?php
	}else if ($acao == 'Subitem'){
	?>
	<p style="margin-left:10px;">
    <span><font face="Tahoma, Geneva, sans-serif" size="3"><?php echo $item.' -> '.$nome; ?></font></span><br />
	</p>
    <p style="margin-left:10px;font-size:14px;font-family:Tahoma, Geneva, sans-serif;">
        <q><?php echo $descricao; ?></q>
    </p>
    
    
		<?php 
		$sql_arq = mysql_query("SELECT arquivo FROM arquivos WHERE id_subiten = $codigo ");
		$sql_num_arq = mysql_num_rows($sql_arq);
		
		if($sql_num_arq > 0) {
		while(list($arquivo)=mysql_fetch_array($sql_arq)){
		?>
            <span style="margin-left:10px;">
                <img src="img/icones/pdf_novo.png" />
                <a title="Visualizar" style="vertical-align:top;text-decoration:none;color:black;font-family:Tahoma, Geneva, sans-serif;" target="_blank" href="../intranet/<?php echo $arquivo; ?>"><?php echo $arquivo; ?></a>
                <a href="inc/baixar.php?arquivo=<?php echo $arquivo; ?>" title="Baixar">
                <img src="img/icones/download.png" />
                </a>
            </span>
            <br />
        <?php 
			}
		}
		?>
	<?php
    }	


?>

